package com.charm.bulkcomponent.ui.activity

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.charm.bulkcomponent.BuildConfig
import com.charm.bulkcomponent.R
import com.charm.codes.FkApplication
import io.reactivex.Observable
import io.reactivex.disposables.Disposable
import java.util.concurrent.TimeUnit

/**
 * Created by tools on 2018/1/3.
 */

class SplashActivity : AppCompatActivity() {
    private var disposable: Disposable? = null
    private var isFirstUsed: Boolean = false
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_splash)
//        disposable = Observable.interval(1000, TimeUnit.MILLISECONDS)
//                .subscribe { goHead() }
        goHead()
    }

    /**
     * 跳转
     */
    private fun goHead() {

        if (isFirstUsed) {
            ARouter.getInstance().build("/common/guide").navigation()
        } else {
            if (FkApplication.isIntegrated) {
                ARouter.getInstance().build("/common/main").navigation()
            } else {
                ARouter.getInstance().build("/common/main/single").navigation()
            }
        }
        if (disposable != null && !disposable!!.isDisposed) {
            disposable!!.dispose()
        }
        finish()
    }
}